/*
 * Copyright 2009 Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.google.gwt.xhr.client;

/**
 * A ready-state callbacks for an {@link XMLHttpRequest} object.
 * You should make a new AbstractProgressHandler instead
 */
public interface ProgressChangeHandler {

  /**
   * This is called whenever the request starts. See
   * {@link XMLHttpRequest#setOnLoadStart}.
   * 
   * @param xhr the object whose state has changed.
   */
  void onLoadStart(XMLHttpRequest xhr);
  
  /**
   * This is called whenever sending and loading data. See
   * {@link XMLHttpRequest#setOnProgress}.
   * 
   * @param xhr the object whose state has changed.
   */
  void onProgress(XMLHttpRequest xhr);
  
  /**
   * This is called whenever the request has been 
   * aborted. For instance, by invoking the abort() method.
   * See {@link XMLHttpRequest#setOnAbort()}.
   * 
   * @param xhr the object whose state has changed.
   */
  void onAbort(XMLHttpRequest xhr);
  
  /**
   * This is called whenever the request has failed. See
   * {@link XMLHttpRequest#setOnError}.
   * 
   * @param xhr the object whose state has changed.
   */
  void onError(XMLHttpRequest xhr);
  
  /**
   * This is called whenever the request has 
   * successfully completed. See
   * {@link XMLHttpRequest#setOnLoad}.
   * 
   * @param xhr the object whose state has changed.
   */
  void onLoad(XMLHttpRequest xhr);
  
  /**
   * This is called whenever the author specified 
   * timeout has passed before the request could 
   * complete.See {@link XMLHttpRequest#setOnTimeOut}.
   * 
   * @param xhr the object whose state has changed.
   */
  void onTimeOut(XMLHttpRequest xhr);
  
  /**
   * This is called whenever the request has completed 
   * (either in success or failure). See
   * {@link XMLHttpRequest#setOnLoadEnd}.
   * 
   * @param xhr the object whose state has changed.
   */
  void onLoadEnd(XMLHttpRequest xhr);

}
